package com.azi.baseconhecimento.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.azi.baseconhecimento.entity.Categoria;
import com.azi.baseconhecimento.service.CategoriaService;

@Controller
public class CategoriaForm {

	@Autowired
	CategoriaService categoriaService;

	@RequestMapping(value = "/categoria/form.htm")
	public ModelAndView init() {
		return new ModelAndView("/categoria/categoriaForm.jsp");
	}

	@RequestMapping(value = "/categoria/salvar.htm", method = RequestMethod.POST)
	public void salvarCategoria(@RequestParam("nome")
	String nome) {

		Categoria categoria = new Categoria();
		categoria.setNome(nome);

		categoriaService.salvarCategoria(categoria);
	}

}
